#delimit ;
*REStat paper "Breastfeeding and Children's Early Cognitive Outcomes";
log using x:/Donnanew/psid08p.log, replace;
clear;
set mem 40m;
set more off;
set matsize 800;

set seed 12345;

use x:/Donnanew/pch082;

**missing obs., dvs;
replace regnc = 0 if regdv == 1;
replace regs = 0 if regdv == 1;
replace regw = 0 if regdv == 1;

replace momhgc = 0 if momhgcdv == 1;
replace dadhgc = 0 if dadhgcdv == 1;
replace mompcraw = 0 if mompcdv == 1;

replace marbirth = 0 if mardv == 1;
replace cath = 0 if reldv == 1;
replace bapt = 0 if reldv == 1;

replace wic97 = 0 if wicdv == 1;


replace fborn = 0 if borddv == 1;
replace sborn = 0 if borddv == 1;

**try an interaction term;

gen fle55 = femch*le55lb;
gen ageble55 = ageb*le55lb;
gen ageb2 = ageb*ageb;


**add in mother's test score;

			psmatch2   bfeed femch black hisp newimmi bapt cath momhgc dadhgc ageb regnc regs regw 
               wic97 marbirth
			   fborn sborn glt35 g3537 le55lb
			   regdv momhgcdv dadhgcdv mardv reldv wicdv borddv
			   mompcraw mompcdv
			   fle55 ageble55 ageb2 
			   , outcome(ap56) trim(3) logit kernel k(epan) bw(.15) common;		
			   
			   
	bs "psmatch2 bfeed femch black hisp newimmi bapt cath momhgc dadhgc ageb regnc regs regw 
               wic97 marbirth
			   fborn sborn glt35 g3537 le55lb
			   regdv momhgcdv dadhgcdv mardv reldv wicdv borddv
			   mompcraw mompcdv
			   fle55 ageble55 ageb2, out(ap56) 
           logit kernel k(epan) bw(.15) trim(3) common" "r(att)", reps(500);		   
			   

			psmatch2   bfeed femch black hisp newimmi bapt cath momhgc dadhgc ageb regnc regs regw 
               wic97 marbirth
			   fborn sborn glt35 g3537 le55lb
			   regdv momhgcdv dadhgcdv mardv reldv wicdv borddv
			   mompcraw mompcdv
			   fle55 ageble55 ageb2
			   , outcome(lw56) trim(3) logit kernel k(epan) bw(.15) common;		
			   
	bs "psmatch2 bfeed femch black hisp newimmi bapt cath momhgc dadhgc ageb regnc regs regw 
               wic97 marbirth
			   fborn sborn glt35 g3537 le55lb
			   regdv momhgcdv dadhgcdv mardv reldv wicdv borddv
			   mompcraw mompcdv
			   fle55 ageble55 ageb2, out(lw56) 
           logit kernel k(epan) bw(.15) trim(3) common" "r(att)", reps(500);		   

			   
**regression based balancing test from Smith paper;
drop if _support==0;

gen pscore2 = _pscore*_pscore;
gen pscore3 = _pscore*_pscore*_pscore;
gen pscore4 = _pscore*_pscore*_pscore*_pscore;
gen bfp = bfeed*_pscore;
gen bfp2 = bfeed*_pscore*_pscore;
gen bfp3 = bfeed*_pscore*_pscore*_pscore;
gen bfp4 = bfeed*_pscore*_pscore*_pscore*_pscore;

reg femch _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg black _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
			   
reg hisp _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
		
reg newimmi _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg bapt _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg cath _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg momhgc _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg dadhgc _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg ageb _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regnc _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regs _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regw _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg wic97 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg marbirth _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg fborn _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
           
reg sborn _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
			
reg glt35 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg g3537 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg le55lb _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg regdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg momhgcdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg dadhgcdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg mardv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
			
reg reldv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
			
reg wicdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg borddv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  
			
reg mompcdv _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg fle55 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg ageble55 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

reg ageb2 _pscore pscore2 pscore3 pscore4 bfeed bfp bfp2 bfp3 bfp4;
test bfeed bfp bfp2 bfp3 bfp4;  

clear matrix;
				 
log close;
